﻿/*************************************************************************
 * Created by OhZee Creative, LLC
 * 2013
 * This code is licensed under Microsoft Public License (Ms-PL)
 * http://opensource.org/licenses/ms-pl
 * http://ozframework.codeplex.com/
 *************************************************************************/

namespace OhZeeCreative.Windows8.Converters
{
	using System;
	using Windows.UI;
	using Windows.UI.Xaml.Data;
	using Windows.UI.Xaml.Media;

    public sealed class ColorToSolidColorBrushConverter : IValueConverter
	{
		public bool ReturnFullName { get; set; }

		public object Convert(object value, Type targetType, object parameter, string language)
		{
			SolidColorBrush brush = null;

			if (value != null)
			{
				Color? nullableColor = value as Color?;

				if (value != null)
				{
					if (nullableColor.HasValue)
					{
						brush = new SolidColorBrush(nullableColor.Value);
					}
				}
				else
				{
					brush = new SolidColorBrush((Color) value);
				}
			}
			return brush;
		}

		public object ConvertBack(object value, Type targetType, object parameter, string language)
		{
			throw new NotImplementedException();
		}
	}
}
